<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LoginPage.aspx.cs" Inherits="Skecthial.UI.Pages.LoginPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Login Box HTML Code - www.PSDGraphics.com</title>
    <link href="../assets/CSS/login-box.css" rel="stylesheet" type="text/css" />
</head>
<body style="background: #CCC;">
    <form id="formLogin" runat="server">
    <div id="fb-root"></div>
    <script>
        window.fbAsyncInit = function () {
            debugger;
            FB.init({
                appId: '299063453508126', // App ID
                status: true, // check login status
                cookie: true, // enable cookies to allow the server to access the session
                xfbml: true  // parse XFBML
            });

            // Additional initialization code here
            FB.Event.subscribe('auth.authResponseChange', function (response) {
                if (response.status === 'connected') {


                    //                FB.api('/me/friends', { fields: 'name,id,location' }, function (response) {
                    //                    debugger;
                    //                    var asd = response;
                    //                });
                    var uid = response.authResponse.userID;
                    var accessToken = response.authResponse.accessToken;
                    var form = document.createElement("form");
                    form.setAttribute("method", 'post');
                    form.setAttribute("action", '/Services/FacebookLogin.ashx');

                    var field = document.createElement("input");
                    field.setAttribute("type", "hidden");
                    field.setAttribute("name", 'accessToken');
                    field.setAttribute("value", accessToken);
                    form.appendChild(field);

                    document.body.appendChild(form);
                    form.submit();
                } else if (response.status === 'not_authorized') {
                    // the user is logged in to Facebook,
                    // but has not authenticated your app
                } else {
                    // the user isn't logged in to Facebook.
                }
            });
        };

        // Load the SDK Asynchronously
        (function (d) {
            var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
            if (d.getElementById(id)) { return; }
            js = d.createElement('script'); js.id = id; js.async = true;
            js.src = "//connect.facebook.net/en_US/all.js";
            ref.parentNode.insertBefore(js, ref);
        }(document));
    </script>
    <div id="login-box">
        <div style="margin-top: -30px;">
            <h1>Login Page</h1>
        </div>
        <br />
        <div id="" style="padding-left: 90px; margin-top: 0px;">
            <fb:login-button size="xlarge" onlogin="require('./log').info('onlogin callback')"
                perms="email,read_friendlists">
                 Facebook
                </fb:login-button>
        </div>
        <p style="padding-left: 180px;">or</p>
        <div id="login-box-name" style="margin-top: 0px;">
            Email:
        </div>
        <div id="login-box-field" style="margin-top: 0px;">
            <input name="q" class="form-login" title="Username" value="" size="30" maxlength="2048" />
        </div>
        <div id="login-box-name">
            Password:
        </div>
        <div id="login-box-field">
            <input name="q" type="password" class="form-login" title="Password" value="" size="30"
                maxlength="2048" />
        </div>
        <br />
        <span class="login-box-options">
            <asp:CheckBox ID="cbRememberMe" runat="server" Text="Remember Me"></asp:CheckBox>
            <a href="#" style="margin-left: 30px;">Forgot password?</a></span>
        <br />
        <br />
        <a href="http://127.0.0.1:3298/">
            <img src="../assets/images/login-btn.png" width="103" height="42" style="margin-left: 90px;" />
        </a>
    </div>
    </form>
</body>
</html>
